package cn.highedu.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration // 声明这个一个配置类
@ComponentScan("cn.highedu.spring") // 配置要扫描的包(到哪些包下扫描带有@Component的注解)
public class ContextConfig {
    public static void main(String[] args) {
        // 获取被Spring IOC容器管理的对象

        // 1.获取Spring IOC容器
        ApplicationContext context = new AnnotationConfigApplicationContext(ContextConfig.class);

        // 2.从Spring IOC容器中获取被管理的对象
        DemoBean demoBean = context.getBean(DemoBean.class);
        demoBean.hello();
    }
}
